export default {
  // 开启命名空间
  namespaced: true,
  // 模块的state数据
  state: () => ({
    // 我的地址数据
    myAddress: JSON.parse(window.localStorage.getItem('address') || '{}'),
    // 编辑地址的信息
    editAddressList: JSON.parse(window.localStorage.getItem('addressList') || '{}'),
    // 地址的索引号 删除地址
    AddressIndex: JSON.parse(window.localStorage.getItem('addressIndex')) || 0,
    // 我的收藏信息
    myCollection: JSON.parse(window.localStorage.getItem('addressCollection')) || [],
    collectionInfomation: [],
    index: 0
  }),
  mutations: {
    // 存储数据
    addMyAddress (state, addressInfo) {
      state.myAddress = addressInfo
      window.localStorage.setItem('address', JSON.stringify(state.myAddress))
    },
    // 存储跳转到编辑地址的数据
    saveEditAddress (state, EditAddress) {
      state.editAddressList = EditAddress
      window.localStorage.setItem('addressList', JSON.stringify(state.editAddressList))
    },
    // 存储索引号
    saveDeleteAddress (state, i) {
      state.AddressIndex = ++i
      window.localStorage.setItem('addressIndex', JSON.stringify(state.AddressIndex))
    },
    // 存储店铺收藏记录
    saveMyCollection (state, info) {
      state.myCollection = info
      window.localStorage.setItem('addressCollection', JSON.stringify(state.myCollection))
    },
    // 改变收藏状态
    changeCollectionStatic (state, i) {
      state.myCollection[i].Collection = !state.myCollection[i].Collection
    },
    changeIndex (state, i) {
      state.index = i
    }
  },
  getters: {}
}
